package autohotkeyide;

import java.io.InputStream;
import java.util.Scanner;

/**
 * @author sad
 */
public class Utils {
    public static String readResourceToString(String resourcePath){
        String path="/resources/"+resourcePath;
        InputStream stream=Utils.class.getResourceAsStream(path);
        if(stream==null){
            throw new RuntimeException("Cannot find resource by path "+path);
        }
        Scanner scanner=new Scanner(stream);
        StringBuilder sb=new StringBuilder(1000);
        boolean first=true;
        while(scanner.hasNextLine()){
            if(first==false){
                sb.append(System.getProperty("line.separator"));
            }
            sb.append(scanner.nextLine());
            first=false;
        }
        scanner.close();
        return sb.toString();
    }
}
